﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class Delivery_DeliveryApplyFileUpload : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        //Response.Write(System.DateTime.Now.ToString("yyyyMMddHHmmss"));
    }

    protected void cmdDeliveryApplyFile_Click(object sender, EventArgs e)
    {
        string filepath = DeliveryApplyFile.PostedFile.FileName;
        string filename = filepath.Substring(filepath.LastIndexOf("\\") + 1);
        string lastname = filename.Substring(filename.LastIndexOf(".") + 1);

        if (filename.Length > 0 && !lastname.Equals("exe"))
        {
            try
            {
                string serverpath = System.DateTime.Now.ToString("yyyyMMddHHmmss") + "-" + filename;
                DeliveryApplyFile.PostedFile.SaveAs(Server.MapPath("~/DeliveryApplyFile/" + serverpath));
                txtDeliveryApplyFileName.Value = serverpath;
                CommonMethod.regAlertMessage("File have Uploaded !", this);
            }
            catch { CommonMethod.regAlertMessage("Upload failed !", this); }
        }
    }
}